package com.twu.biblioteca.reservation;

import com.twu.biblioteca.exceptions.BookAlreadyReservedException;
import com.twu.biblioteca.exceptions.InexistantBookException;
import com.twu.biblioteca.exceptions.InvalidBookIdException;
import com.twu.biblioteca.model.BookList;

import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;
import java.util.UUID;

/**
 * Created with IntelliJ IDEA.
 * User: cschlumb
 * Date: 06/08/2013
 * Time: 14:17
 * To change this template use File | Settings | File Templates.
 */
public class ReservationParser {

    private final InputStream inputStream;

    public ReservationParser(InputStream inputStream) {
        this.inputStream = inputStream;
    }

    public UUID parseInput() throws InvalidBookIdException {
        Scanner s = new Scanner(inputStream).useDelimiter("\n");
        try {
            return UUID.fromString(s.next());
        } catch (IllegalArgumentException e){
            throw new InvalidBookIdException();
        }
    }
}
